package com.kandinfo.base.security.aspectj;

import org.apache.shiro.aspectj.AspectjAnnotationsAuthorizingMethodInterceptor;
import org.apache.shiro.aspectj.BeforeAdviceMethodInvocationAdapter;
import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.aspectj.lang.annotation.Pointcut;

@Aspect()
public class ShiroAnnotationAuthorizingAspect {
	private static final String pointCupExpression = "execution(@com.kandinfo.k12.tiku.common.security.annotation.ACLPermission * *(..))";

	@Pointcut(pointCupExpression)
	public void anyShiroAnnotatedMethod() {
	}

	@Pointcut(pointCupExpression)
	void anyShiroAnnotatedMethodCall(JoinPoint thisJoinPoint) {
	}

	private AspectjAnnotationsAuthorizingMethodInterceptor interceptor = new AspectjAnnotationsAuthorizingMethodInterceptor();

	@SuppressWarnings("unused")
	@Before("anyShiroAnnotatedMethodCall(thisJoinPoint)")
	public void executeAnnotatedMethod(JoinPoint thisJoinPoint) {

		// 1. Adapt the join point into a method invocation
		BeforeAdviceMethodInvocationAdapter mi = BeforeAdviceMethodInvocationAdapter
				.createFrom(thisJoinPoint);

		// 2. Delegate the authorization of the method call to the super class

	}
}
